<template>
	<div class="Administration">
		<van-collapse v-model="activeNames">
			<van-collapse-item :title="item.name" :name="index+1" v-for="(item,index) in list" :key="index">
				<div class="list-item" v-for="str in item.child" :key="str.id" @click="todetail(str)">
					<span class="title">{{str.title}}</span>
					<span class="tiem">{{str.publishtime_text}}</span>
				</div>
			</van-collapse-item>
		</van-collapse>
	</div>
</template>

<script>
	export default {
		name: "Administration",
		components: {

		},
		data() {
			return {
				activeNames: [],
				siteType:1,
				list:''
			}
		},
		mounted() {
			this.siteType = this.$localStorage.get("siteType")
		},
		methods:{
			
			getData(item){
				this.title = item.name
				this.$api.home.nav({type:this.siteType,pid:item.id}).then(res => {
					// 执行某些操作
					if (res.code == 1) {
						this.list = res.data
						this.getArticle()
					}
				
				})
			},
			getArticle(){
				let that = this
				this.list.forEach(item=>{
					that.$api.home.articleList({category_id:item.url,limit:10,page:1}).then(res => {
						// 执行某些操作
						if (res.code == 1) {
							that.$set(item,"child",res.data.data)
						}
					
					})
				})
				
			},
			todetail(item){
				this.$router.push({name:'articledetail',query:{id:item.id}})
			}
		}


	}
</script>

<style scoped lang="less">
	.Administration{
		margin-top: 0.25rem;
		.list-item{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 0.25rem;
			.title{
				font-size:0.81rem;
				font-family:PingFang SC;
				font-weight:500;
				display: inline-block;
				width: 60%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
			.time{
				font-size:0.81rem;
				font-family:PingFang SC;
				font-weight:500;
				color:rgba(89,89,89,1);
			}
		}
	}
</style>
